#include<iostream>
#include<unistd.h>
#include<vector>
#include"Thread.hpp"
#include"ThreadPool.hpp"
#include"Task.hpp"

using namespace std;

int main() {
    ThreadPool<Task>* tp = new ThreadPool<Task>(5);
    tp->Start();  // Start 方法中为每个线程绑定 HandlerTask 并启动

    srand(time(nullptr));
    while (true) {
        // 生成任务并推入线程池
        int x = rand() % 10 + 1;
        usleep(1000);
        int y = rand() % 5;
        int len = opers.size();
        char op = opers[rand() % len];
        Task t(x, y, op);
        tp->Push(t);

        cout << "main thread make a task: " << t.GetTask() << endl;
        sleep(1);
    }

    return 0;
}